let db = require('../db/dbmanager');
const crypto = require('crypto');
/**
 * 管理员账号
 */
let Admin={
    checklogin:async(account,password)=>{
        let p =await new Promise(function(resolve,reject){
            let sha256=crypto.createHash('SHA256').update(password).digest('hex');
            let sql = "SELECT * FROM ADMIN WHERE username=$username and password=$password";
            let param = {$username:account, $password:sha256};
            db.sqliteDB.all(sql,param,function(err,row){
                if(err){
                    reject(err);
                }else{
                    resolve(row);
                }
            });
        });
        return p;
    },
    insert:function(account, password){
        
    }
};

module.exports = Admin;